<?php

namespace Wentaophp\Yii2Aop;

use Wentaophp\Yii2Aop\Command\ProxyClearCacheCommand;
use yii\base\BootstrapInterface;

/**
 * aop module definition class
 */
class Module extends \yii\base\Module implements BootstrapInterface
{

    const MODULE_ID = 'aop';
    /**
     * {@inheritdoc}
     */
    public $id = self::MODULE_ID;

    /**
     * {@inheritdoc}
     */
    public function init()
    {
        parent::init();
        // custom initialization code goes here
    }

    public function bootstrap($app)
    {

        if ($app instanceof \yii\web\Application) {
            (new ProxyServiceProvider())->webInit();
        } elseif ($app instanceof \yii\console\Application) {
            $app->controllerMap[$this->id] = [
                'class' => ProxyClearCacheCommand::class
            ];
        }
    }
}
